package com.org.entity.sys;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.org.entity.base.BaseEntity;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.Date;

@Data
@Table(name = "SYS_USER")
public class SysUser extends BaseEntity {

    /**
     * 用户姓名
     */
    @Column(name = "NAME")
    @NotBlank(message = "姓名不能为空！")
    private String name;

    /**
     * 登录账号
     */
    @Column(name = "LOGIN_CODE")
    @NotBlank(message = "账号不能为空！")
    private String loginCode;

    /**
     * 用户密码
     */
    @Column(name = "PASSWORD")
    private String password;

    /**
     * 用户邮箱
     */
    @Email(message = "邮箱格式不正确")
    @Column(name = "EMAIL")
    private String email;

    /**
     * 手机号码
     */
    @Column(name = "PHONE")
    @Pattern(regexp = "^(((13[0-9])|(14[579])|(15([0-3]|[5-9]))|(16[6])|(17[0135678])|(18[0-9])|(19[89]))\\d{8})$", message = "手机号格式错误")
    private String phone;

    /**
     * 性别
     */
    @Column(name = "SEX")
    @NotNull(message = "性别不能为空！")
    private Integer sex;

    /**
     * 用户状态
     */
    @Column(name = "STATE")
    private int state;

    /**
     * 部门编码
     */
    @Column(name = "FK_DEPARTMENT_CODE")
    private String fkDepartmentCode;

    /**
     * 部门名称
     */
    @Transient
    private String departmentName;

    /**
     * 注册时间
     */
    @CreatedDate
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Column(name = "ADD_TIME")
    private Date addTime;

    /**
     * 添加用户人
     */
    @Column(name = "ADD_USER_ID")
    private String addUserId;

    /**
     * 修改时间
     */
    @Column(name = "MODIFY_TIME")
    private Date modifyTime;

    /**
     * 修改人
     */
    @Column(name = "MODIFY_USER_ID")
    private String modifyUserId;

}


